import Tracker from '../utils/trackSDK'

export function blankScreen () {
  let wrapperElements = ['html', 'body', '#container', '.content.main']
  let emptyPoint = 0

  function getSelector (element) {
    if (element.id) {
      return '#' + element.id
    }
  }

  function isWrapper (element) {
    let selector = getSelector(element)
    if (wrapperElements.includes(selector)) {
      emptyPoint++
    }
  }
  
  for (var i = 1; i <= 9;i++) {
    let xElement = document.elementFromPoint(window.innerWidth * i / 10, window.innerHeight / 2)
    let yElement = document.elementFromPoint(window.innerWidth / 1, window.innerHeight * i / 10)
    isWrapper(xElement[0])
    isWrapper(yElement[0])
  }

  if (emptyPoint > 16) {
    Tracker.send({
      kind: 'stability',
      type: 'blank',
      emptyPoint,
      // selector: getSelector(),
      isBlankScreen: true
    })
  }
}